import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_verify/lf_verify_id_confirm/lf_verify_id_confirm_logic.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:largefriends/res/strings/lf_strings.dart';
import 'package:largefriends/widgets/lf_app_bar.dart';
import 'package:wechat_assets_picker/wechat_assets_picker.dart';

import '../../../res/lf_fonts.dart';
import '../../../res/lf_text_style.dart';
import '../../../widgets/lf_button.dart';
import '../../../widgets/lf_image_picker.dart';

class LfVerifyIdConfirmPage extends StatefulWidget {
  const LfVerifyIdConfirmPage({super.key});

  @override
  State<LfVerifyIdConfirmPage> createState() => _LfVerifyIdConfirmPageState();
}

class _LfVerifyIdConfirmPageState extends State<LfVerifyIdConfirmPage> {
  final logic = Get.put(LfVerifyIdConfirmLogic());

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: Scaffold(
          appBar: lfAppBar(
            title: strVerifyID.tr,
            leadingCallback: () {
              Get.back();
            },
          ),
          body: GetBuilder<LfVerifyIdConfirmLogic>(
            builder: (controller) {
              return Padding(
                padding: EdgeInsets.symmetric(horizontal: 15.w),
                child: CustomScrollView(
                  slivers: [
                    20.h.sbh.sliverBox,
                    SizedBox(
                      height: 300.h,
                      child: AssetEntityImage(
                        controller.image,
                        fit: BoxFit.contain,
                      ),
                    ).sliverBox,
                    10.h.sbh.sliverBox,
                    Padding(
                      padding: EdgeInsets.symmetric(horizontal: 15.w),
                      child: LfButton(
                        text: strSubmit.tr.toUpperCase(),
                        onPress: () {
                          controller.verifyID();
                        },
                        enabled: true,
                      ),
                    ).sliverBox,
                    10.h.sbh.sliverBox,
                    Padding(
                      padding: EdgeInsets.symmetric(horizontal: 35.w),
                      child: InkWell(
                        child: Container(
                          padding: EdgeInsets.symmetric(vertical: 12.h),
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              borderRadius: 40.r.radius,
                              border:
                                  Border.all(color: colorFEFEFE, width: 2.r)),
                          child: Text(
                            strRetry.tr,
                            style: lfTextStyle(
                                sp: 17.sp,
                                fontFamily: fontBold,),
                          ),
                        ),
                        onTap: () {
                          LfImagePicker.pickerImage((file) {
                            if (file.isNotEmpty) {
                              logic.image = file.first;
                              logic.update();
                            }
                          }, maxCount: 1);
                        },
                      ),
                    ).sliverBox,
                    30.h.sliverBox,
                  ],
                ),
              );
            },
          ),
        ),
        onWillPop: () async {
          Get.back();
          return true;
        });
  }
}
